package com.company.strs;

import java.util.Arrays;

public class Anagram {
    public boolean isAnagram(String s, String t) {
        if (s == null&&t==null) {
            return true;
        }
        if (s.length()==0&&t.length()==0) {
            return true;
        }

        if (s.length()!=t.length()) {
            return false;
        }
        char[] a = s.toCharArray();
        char[] b = t.toCharArray();
        Arrays.sort(a);
        Arrays.sort(b);
        for (int i = 0; i < a.length; i++) {
            if (a[i] !=b[i]) {
                return false;
            }
        }
        return true;
    }
}
